package global

import (
	"bytes"
	"errors"
	"runtime"
	"strings"
)

var (
	ErrNil = errors.New("error nil value") // nil错误

	BasePath = GenerateBasePath() // 基础路径，即项目路径
)

func GenerateBasePath() string {
	_, f, _, _ := runtime.Caller(0)
	i := strings.Index(f, PackageName)
	ii := bytes.LastIndexAny([]byte(f)[:i-1], "/")
	return f[:ii+1]
}

func GetGetCodePath() string {
	_, f, _, _ := runtime.Caller(1)
	return strings.Replace(f, BasePath, "", 1)
}
